﻿using QuickDial_5_0.Controller;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuickDial_5_0.View.Default
{
    public partial class FrmMain : Form
    {
        FrmMainController controller;
        Timer tmMain;
        public FrmMain()
        {
            InitializeComponent();
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            controller = new FrmMainController();
            this.Text = "QuickDial 5.0";
            Config_MenuClickEvent();
            Config_StatusClickEvent();
            Config_Timer();
        }

        /// <summary>
        /// 重新加载事件
        /// </summary>
        /// <remarks>2015-8-12 SoChishun Added.</remarks>
        public void Frm_Reload()
        {

        }
        /// <summary>
        /// 配置菜单点击事件
        /// </summary>
        private void Config_MenuClickEvent()
        {
            mi_退出.Click += mi_Click;
        }
        /// <summary>
        /// 菜单点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mi_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmi = (ToolStripMenuItem)sender;
            switch (tsmi.Name)
            {
                case "mi_退出":
                    if (DialogResult.OK == MessageBox.Show("您确定要退出程序吗?", "确认", MessageBoxButtons.OKCancel))
                    {
                        Application.Exit();
                    }
                    break;
                case "mi_选项":
                    break;
            }
        }

        /// <summary>
        /// 配置状态栏点击事件
        /// </summary>
        private void Config_StatusClickEvent()
        {
            status_time.Click += (object sender, EventArgs e) =>
              {
                  FormHelper.Show<FrmCalendar>();
              };
        }
        /// <summary>
        /// 主界面时钟设置
        /// </summary>
        /// <remarks>2015-8-12 SoChishun Added.</remarks>
        private void Config_Timer()
        {
            tmMain = new Timer()
            {
                Interval = 1000,
                Enabled = true
            };
            tmMain.Tick += (object sender, EventArgs e) =>
            {
                status_time.Text = DateTime.Now.ToString("HH:mm") + " " + DateTime.Today.ToString("dddd");
            };
        }
    }
}
